/*
 * Copyright (c) 2006, 2022, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

import java.util.Arrays;
import java.util.Random;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import java.util.stream.Stream;

/**
 * <p>Project: jse2204 - Stream5
 * <p>Powered by webrx On 2022-09-28 17:14:39
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class Stream5 {
    public static void main(String[] args) {
        //数组 和 流相互转换
        int[] num = new int[3];
        IntStream s1 = Arrays.stream(num);
        //int[] a2 = s1.toArray();

        Stream<Integer> s2 = s1.boxed();
        Integer[] a3 = new Integer[3];
        s2.toList().toArray(a3);
        System.out.println(Arrays.toString(a3));

        //利用IntStream流生成10随机整数，将其转换为Set<Integer>
        Set<Integer> sets =  IntStream.generate(()->new Random().nextInt(1,101)).limit(10).boxed().collect(Collectors.toSet());
        System.out.println(sets);


    }
}
